//
//  CCForumTableViewCell.m
//  CwinCar
//
//  Created by dlios on 15/10/15.
//  Copyright © 2015年 dlios. All rights reserved.
//

#import "CCForumTableViewCell.h"
#import "BaseHeader.h"
@implementation CCForumTableViewCell

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.postImageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, mainScreen_Width / 2.884, mainScree_Height / 7.411)];
        self.postImageView.layer.masksToBounds = YES;
        self.postImageView.layer.cornerRadius = 8.* suitableScreen_Width;
        [self.contentView addSubview:self.postImageView];
        
        self.postTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 2.678, 5, mainScreen_Width / 1.704, mainScree_Height / 16.675)];
        self.postTitleLabel.textColor = [UIColor blackColor];
        
        [self.postTitleLabel setNumberOfLines:0];
        [self.contentView addSubview:self.postTitleLabel];
        
        self.forumNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 2.678, mainScree_Height / 10.261, mainScreen_Width / 2.5, mainScree_Height / 39.235)];
        self.forumNameLabel.textColor = [UIColor grayColor];
        self.forumNameLabel.alpha = .6;
        [self.contentView addSubview:self.forumNameLabel];
        
        self.viewCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 1.25, mainScree_Height / 11.116, mainScreen_Width / 5.357, mainScree_Height / 22.233)];
        self.viewCountLabel.textColor = [UIColor grayColor];
        self.viewCountLabel.alpha = .6;
        [self.contentView addSubview:self.viewCountLabel];
        
        self.talking = [[UIImageView alloc]initWithFrame: CGRectMake(mainScreen_Width / 1.363, mainScree_Height / 10.261, mainScreen_Width / 22.058, mainScree_Height / 39.235)];
        [self.talking setImage:[UIImage imageNamed:@"iconfont-iconfontpinglun"]];
        [self.contentView addSubview:self.talking];
        self.tableLine = [[UILabel alloc]initWithFrame:CGRectMake(15, (mainScree_Height - 5) / 6.67, mainScreen_Width - 30, 1)];
        self.tableLine.backgroundColor = [UIColor colorWithRed:0.265 green:0.508 blue:0.939 alpha:1.000];
        [self.contentView addSubview:self.tableLine];
        
        if (mainScree_Height == 736)
        {
            self.postTitleLabel.font = [UIFont systemFontOfSize:16];
            self.forumNameLabel.font = [UIFont systemFontOfSize:15];
            self.viewCountLabel.font = [UIFont systemFontOfSize:14];
            
        } else if (mainScree_Height == 667)
        {
            self.postTitleLabel.font = [UIFont systemFontOfSize:16];
            self.forumNameLabel.font = [UIFont systemFontOfSize:14];
            self.viewCountLabel.font = [UIFont systemFontOfSize:14];
            
            
        } else if (mainScree_Height == 568)
        {
            self.postTitleLabel.font = [UIFont systemFontOfSize:13];
            self.forumNameLabel.font = [UIFont systemFontOfSize:12];
            self.viewCountLabel.font = [UIFont systemFontOfSize:12];
            
        } else if (mainScree_Height == 480)
        {
            self.postTitleLabel.font = [UIFont systemFontOfSize:12];
            self.forumNameLabel.font = [UIFont systemFontOfSize:11];
            self.viewCountLabel.font = [UIFont systemFontOfSize:11];
            
        }
        
    }
    return self;
}

- (void)setData:(CCForumModel *)model
{
    [self.postImageView sd_setImageWithURL:[NSURL URLWithString:model.postImage] placeholderImage:[UIImage imageNamed:@"zhanweitu"]];
    [self.postTitleLabel setText:model.postTitle];
    [self.viewCountLabel setText:[NSString stringWithFormat:@"%@",model.viewCount]];
    [self.forumNameLabel setText:model.forumName];
}

@end
